package Thread_;

import java.util.concurrent.Semaphore;

/**
 * semaphere:信号量
 * acquire:申请资源
 * release：释放资源
 */
public class Thread26 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(1);//设可用资源数为1；也就相当于一个锁了
        semaphore.acquire();
        System.out.println("信号量 1");
        semaphore.acquire();
        System.out.println("信号量 2");
        semaphore.acquire();
        System.out.println("信号量 3");
        semaphore.release();
    }

}
